43. Timing Your NB Classifier

Timing Your NB Classifier

Question:

An important topic that we didn’t explicitly talk about is the time to train and test our algorithms. Put in two lines of code, above and below the line fitting your classifier, like this:

t0 = time()
< your clf.fit() line of code >
print "training time:", round(time()-t0, 3), "s"

Put similar lines of code around the clf.predict() line of code, so you can compare
the time to train the classifier and to make predictions with it. What is faster, training or prediction?

We will compare the Naive Bayes timing to a couple other algorithms, so note down the speed and accuracy you get and we’ll revisit this in the next mini-project.

Start Quiz: